home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / System 7.0 Samples / Edition Manager / Print.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-03  |  2.3 KB  |  76 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2.  *
  3.  *  Apple Developer Technical Support
  4.  *
  5.  *  Printing routines
  6.  *
  7.  *  Program:    EditionSample
  8.  *  File:       Print.c -    C Source
  9.  *
  10.  *  by:         C.K. Haun <TR>
  11.  *
  12.  *  Copyright © 1990,1991 Apple Computer, Inc.
  13.  *  All rights reserved.
  14.  *
  15.  *------------------------------------------------------------------------------
  16.  * This file does the printing for this application
  17.  *----------------------------------------------------------------------------*/
  18.  
  19. #define __PRINTSTUFF__
  20.  
  21. #pragma load "EdSampheaders"                                /* see the Buildheaders.c file */
  22.  
  23. #include "EdSampdefines.h"
  24. /* prototypes */
  25.  
  26.  
  27. #pragma segment Print
  28. void PrintIt(WindowPtr theWind);
  29.  
  30. /* external references */
  31.  
  32. /* PrintIt prints the window passed to it.  The Boolean tells the function */
  33. /* what to do when printing is finished.  This is in place if Print was selected */
  34. /* from the Finder, the window will be closed after it's been printed */
  35. /* and the application will exit */
  36.  
  37. void PrintIt(WindowPtr theWind)
  38. {
  39.     THPrint myPrintRec;
  40.     TPPrPort myPrintPort;
  41.     TPrStatus myStats;
  42.     extern WindowPtr gCurrentWindow;
  43.     extern Boolean gShowPub;
  44.     extern Boolean gShowSub;
  45.     extern Boolean gShowingAll;
  46.     Boolean temp1, temp2, temp3;
  47.     windowCHandle drawers;
  48.     temp1 = gShowPub;
  49.     temp2 = gShowSub;
  50.     temp3 = gShowingAll;
  51.     gShowPub = gShowSub = gShowingAll = false;
  52.     drawers = (windowCHandle)GetWRefCon(gCurrentWindow);
  53.     HLock((Handle)drawers);                                 /* lock it down so things don't get stupid */
  54.     PrOpen();
  55.     myPrintRec = (THPrint)NewHandle(sizeof(TPrint));
  56.     PrintDefault(myPrintRec);
  57.     if (PrJobDialog(myPrintRec)) {
  58.         myPrintPort = PrOpenDoc(myPrintRec, nil, nil);
  59.         PrOpenPage(myPrintPort, nil);
  60.         /* jump to the drawing function stored for this window */
  61.         (ProcPtr)((*drawers)->drawMe)(drawers, gCurrentWindow);
  62.         HUnlock((Handle)drawers);                           /* all done */
  63.         PrClosePage(myPrintPort);
  64.         PrCloseDoc(myPrintPort);
  65.         PrPicFile(myPrintRec, nil, nil, nil, &myStats);
  66.     }
  67.     DisposHandle((Handle)myPrintRec);
  68.     PrClose();
  69.     gShowPub = temp1;
  70.     gShowSub = temp2;
  71.     gShowingAll == temp3;
  72. }
  73.  
  74.  
  75. #undef __PRINTSTUFF__
  76.